﻿/*================================================================================================
	TASK 9:                                                                               {Loop's}
	In the combinatorial mathematics, the Catalan numbers are calculated by the following formula: 
    http://en.wikipedia.org/wiki/Catalan_number
================================================================================================*/

using System;

class CatalanNumbers
{
    static void Main()
    {
        Console.Write("Enter n=");
        double n = double.Parse(Console.ReadLine());

        double catalan = 1;
        double nextCatalan;
        double facZnamenatel;
        double facChislitel ;

        bool definitionMultiplicity = (n > 0) || (n == 0);

        if (definitionMultiplicity)
        {

            for (int i = 2; i <= n; i++)
            {
                facChislitel = n + i;
                facZnamenatel =i*1;
                nextCatalan =facChislitel / facZnamenatel;
                catalan = catalan*nextCatalan;
            }

        }
        else
        {
            Console.WriteLine("Enter positive number");
        }

        Console.WriteLine(catalan);
    }
}

